#include <iostream>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Geometry>

const int SIZE = 100;

using namespace std;
using namespace Eigen;

int main()
{
    // AX=B
    Matrix<double, Dynamic, Dynamic> A; 
    
    A = MatrixXd::Random(SIZE, SIZE);   
    A = A.transpose() * A;

    Matrix<double, Dynamic, 1> B;
    B = MatrixXd::Random(SIZE, 1);
    Matrix<double, Dynamic, 1> X;
    X = MatrixXd::Random(SIZE, 1);      

    // Cholesky
    X = A.llt().solve(B);               
    cout << "LLT result:\n" << X << endl;

    // // QR
    X = A.colPivHouseholderQr().solve(B);
    cout << "QR result:\n" << X << endl; 
    return 0;
}